﻿using BasicData.Application.Input;
using BasicData.Application.Input.BOM;
using BasicData.Application.Output;
using BasicData.Application.Services.BOM;
using BasicData.Result;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicData.Api.Controllers
{
    ///<summary>
    /// BOM
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
   
    public class BomController : ControllerBase
    {
        IBOMServices services;
        ILogger<BomController> logger;

        public BomController(IBOMServices services, ILogger<BomController> logger)
        {
            this.services = services;
            this.logger = logger;
        }
        /// <summary>
        /// 添加BOM
        /// </summary>
        [HttpPost]
       
        public ApiResult<int> AddBom(BomInput input)
        {
            logger.LogInformation("添加BOM");
            return services.AddBom(input);
        }

        /// <summary>
        /// 删除BOM
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPut]
        
        public ApiResult<int> DeleteBom(long id)
        {
            logger.LogInformation("删除BOM");
            return services.DeleteBom(id);
        }
        /// <summary>
        /// 获取BOM
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<BomOutput> GetBom([FromQuery]PageInput input)
        {
            logger.LogInformation("获取BOM");
            return services.GetBom(input);
        }
        /// <summary>
        /// 修改BOM
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateBom(UpdateBomInput input)
        {
            logger.LogInformation("修改BOM");
            return services.UpdateBom(input);
        }

        /// <summary>
        /// 添加BOM配件
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddBomSparepart(BomSparepartInput input)
        {
            logger.LogInformation("添加BOM配件");
            return services.AddBomSparepart(input);
        }
        /// <summary>
        /// 获取BOM配件
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<BomSparepartOutput> GetBomSparepart([FromQuery]PageInput input)
        {
            logger.LogInformation("获取BOM配件");
            return services.GetBomSparepart(input);
        }
        /// <summary>
        /// 修改BOM配件
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateBomSparepart(UpdateBomSparepart input)
        {
            logger.LogInformation("修改BOM配件");
            return services.UpdateBomSparepart(input);
        }
        /// <summary>
        /// 删除BOM配件
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> DeleteBomSparepart(long id)
        {
            logger.LogInformation("删除BOM配件");
            return services.DeleteBomSparepart(id);
        }
    }
}
